<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="lib/jquery-3.3.1.js"></script>
    <style>
    div.one{
        height:1200px;
        background: #44cef6;
    }
    .fix{
        width:30px;
        height:70px;
        background: #ff2d51;
        position: fixed;
        z-index: 100;
        bottom:100px;
        right:10px;
        display: none;
    }
    </style>
</head>
<body>
    <div class="one">

    </div>
    <div class="fix">

    </div>
    <script>
        /* scrollTop<70,fix隐藏；scrollTop>70,fix显示   */
    $(window).scroll(function(){
        var scroll = $(window).scrollTop();
        console.log(scroll);
        if(scroll>70){
            $(".fix").fadeIn(300)
        }else{
            $(".fix").fadeOut(300)
        }
    })

    $(".fix").click(function(){
        $("html,body").animate({ scrollTop:0},300)
    })
        </script>
</body>
</html>